package com.qj.sys;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.concurrent.ThreadPoolExecutor;

@SpringBootTest(classes = {SysApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@RunWith(SpringRunner.class)
@Slf4j
public class ThreadPoolTest {

    @Resource(name = "mailThreadPool")
    private ThreadPoolExecutor mailThreadPool;

    @Resource(name = "phoneThreadPool")
    private ThreadPoolExecutor phoneThreadPool;

    @Test
    public void test() {
        for (int i = 0; i < 10; i++) {
            mailThreadPool.submit(() -> log.info("当前时间:" + System.currentTimeMillis()));
        }
    }

    @Test
    public void test2() {
        for (int i = 0; i < 10; i++) {
            phoneThreadPool.submit(() -> log.info("当前时间:" + System.currentTimeMillis()));
        }
    }
}